﻿using System;
using System.Collections.Generic;
using System.Text;
using PacMan3D.Utils;
using Tao.OpenGl;

namespace PacMan3D.Objects
{
    public class Fog
    {
        private bool FogEnabled;
        private float density = 0.25f;
        //private float zNear = 3.0f; // Fog Start Distance
        //private float zFarD = 100.0f; // Fog End Distance
        private RGBAColor Color;

        public Fog()
        {
            this.Color = new RGBAColor(StandardColors.White, 1.0f);

            Gl.glEnable(Gl.GL_FOG);
            Gl.glFogfv(Gl.GL_FOG_COLOR, new float[] { this.Color.Red, this.Color.Green, this.Color.Blue }); // Set the Fog Color
            Gl.glFogi(Gl.GL_FOG_MODE, Gl.GL_EXP); // Fog Mode: GL_EXP, GL_EXP2, GL_LINEAR
            Gl.glFogf(Gl.GL_FOG_DENSITY, density); // How Dense Will The Fog Be

            // GL_LINEAR: 
            // Gl.glFogf(Gl.GL_FOG_START, zNear);  // Fog Start Depth
            // Gl.glFogf(Gl.GL_FOG_END, zFarD);    // Fog End Depth
            
            Gl.glDisable(Gl.GL_FOG);
            this.FogEnabled = false;
        }

        public void Enable()
        {
            this.FogEnabled = true;
            Gl.glEnable(Gl.GL_FOG); // Enables GL_FOG
        }

        public void Disable()
        {
            this.FogEnabled = false;
            Gl.glDisable(Gl.GL_FOG); // Disables GL_FOG
        }

        public void ChangeStatus()
        {
            if (this.FogEnabled)
                Disable();
            else
                Enable();
        }
    }
}
